package order

import "time"

// 订单信息

// Address 地址信息
type Address struct {
	City     string
	District string
	Street   string
}

// Customer 客户信息
type Customer struct {
	ID        int64
	Name      string
	Phone     string
	Addresses map[string]Address // 客户地址
}

// OrderItem 商品项
type OrderItem struct {
	ProductId string
	Name      string
	Price     float64
	Quantity  int
}

// Order 订单信息
type Order struct {
	ID          string
	CreateAt    time.Time
	Customer    Customer
	Items       []OrderItem
	TotalAmount float64 // 订单总金额
}

func (r *Order) CalculateTotal()  {
	total := 0.0
	for _, item := range r.Items {
		total += item.Price * float64(item.Quantity)
	}
	r.TotalAmount = total
}